﻿<cfscript>
/** 
* Course Mark Translater Service
* 
* @hint "Course Mark Translater Service" 
*/ 

component 
	displayname="public.service.util.LogAdvice" 
	output=false 
	{
		
	/*PROPERTIES*/
	property name="datetimeAdvice" hint="日期时间操作组件";
	property name="sessionAdvice" hint="会话组件";
	property name="securityAdvice" hint="安全组件";
	property name="sequenceLogInfo" hint="日记组件";
	
	/**
	* @hint "初始化对象"
	*/
	public public.service.util.LogAdvice function init() output=false {
		return this;
	}

	
	
	/*
		日记类型 
		
		1  登录日记
		2   
	
	
	
	*/
	
	
	/**
	* @hint "操作日记"
	* 
	* @type "操作类型"
	* @content "具体描述"
	*/

	public void function writeLog( required string type, required string content ) output=false {
		
		var sequence = getsequenceLogInfo();
		
		var logId = sequence.getLogId();
		
		/* 当前日期时间字符串 */
		var currentDateTime = getdatetimeAdvice().getCurrentDatetimeString();
			
		//操作人员
		var userId = getsessionAdvice().getAutherUserID();
		
		var ip = getsecurityAdvice().getIP();
		
		transaction{
		
			switch( type ){
				case 1:
					var sql = "INSERT INTO t_loginfo(log_id, log_type, user_id,log_content,log_ip,log_time) values(
									   :logId, :logType :userId, :content, :logIp, :logTime 
								)";
								
					var queryObj = new Query( datasource=application.dnsMaster );
					
					queryObj.addParam( name="logId", value=logId, cfsqltype="cf_sql_varchar" );
					queryObj.addParam( name="logType", value=type, cfsqltype="cf_sql_varchar" );
					queryObj.addParam( name="userId", value=userId, cfsqltype="cf_sql_varchar" );
					queryObj.addParam( name="content", value=content, cfsqltype="cf_sql_varchar" );
					queryObj.addParam( name="logIp", value=ip, cfsqltype="cf_sql_varchar" );
					queryObj.addParam( name="logTime", value=currentDateTime, cfsqltype="cf_sql_varchar" );
					
					queryObj.execute( sql=sql );
					
					break;
				case 2:
					break;
				case 3: 
					break;
					
			}
		
		}
		
	}
}
	
</cfscript>